import {
  getMessageInfo,
 } from './services';

export default {
  namespace: 'messagesDetail',
  state: {
      data: {},
  },
  effects: {
    *fetchMessageInfo({ payload }, { call, put }) {
      const response = yield call(getMessageInfo, payload);
      //console.log(response)
      const { code, data, msg } = response
      if (code === 1) {
        yield put({
          type: 'save',
          payload: data,
        });
        return Promise.resolve(msg)
      }
      return Promise.reject(msg)
    },
  },
  reducers: {
    save(state, { payload }) {
      state.data = payload
      return state
    },
  },
};
